package TeachLesson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "addSolveProServlet")
public class addSolveProServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取各项参数
        String workerNo=request.getParameter("workerNo");
        String courseNo=request.getParameter("courseNo");
        String title=request.getParameter("title");
        String realText=request.getParameter("realText");

        SolveProDao solveProDao=new SolveProDao();
        int row=solveProDao.addSolvePro(workerNo,courseNo,title,realText);
        if(row>0){
            response.sendRedirect("/Teachers/SolvePro.jsp?courseNo="+courseNo+"&workerNo="+workerNo);
        }else {
            response.getWriter().println("添加失败,请后退重试");
        }
    }
}
